package com.curluin.model;

import com.curluin.controll.Controller;
import com.curluin.math.MyVector;
import com.curluin.scene.Node;
import com.curluin.scene.TextureNode;
import com.curluin.scene.TriangleMesh;

public class Water extends Ground implements Obstacle {

	public Water(MyVector position,int positionMode, float b, float h,
			float l) {
		super(0, Controller.GAMEPHASE_WATER, position, positionMode, b, h, l, TriangleMesh.WATER_BLUE, ModelObject.CONSITENCY_FLUID);
		if(this.getClass().equals(Water.class)){
			initialize(position, positionMode);
			node.setPosition(position, Node.RESET, positionMode);
		}
	}
	
	public Water(MyVector position,int positionMode,float[] sizeTexPerDim, int[] numTexPerDim, final int textureResourceId) {

		super(0, Controller.GAMEPHASE_WATER, position, positionMode, sizeTexPerDim, numTexPerDim, textureResourceId, CONSITENCY_FLUID);
		if(this.getClass().equals(Water.class)){
			initialize(position, positionMode);
			node.setPosition(position, Node.RESET, positionMode);
			debugColor = TriangleMesh.WATER_BLUE;
		}
		TextureNode texNode = new TextureNode(textureResourceId);
	    texNode.addChild(this.node.getChildren().firstElement());
		this.node.getChildren().clear();
		this.node.addChild(texNode);
	}
	
	public Water(MyVector position,int positionMode, float b, float h,
			float l, final int textureResourceId) {
		this(position, positionMode, b, h, l);
		
		TextureNode texNode = new TextureNode(textureResourceId);
	    texNode.addChild(this.node.getChildren().firstElement());
		this.node.getChildren().clear();
		this.node.addChild(texNode);
	}

	@Override
	public MyVector detailledCollisionCheck(ModelObject mo) {
		//TODO get exact position
		MyVector res=null;
		if(mo.getCenter().get(1)<=getCenter().get(1)) res= mo.position;
		
		return res;
	}


}
